package com.tsingteng.cosfun.ui.mine.attent;

import com.tsingteng.cosfun.bean.AttentFansbean;
import com.tsingteng.cosfun.bean.AttentRecommendbean;
import com.tsingteng.cosfun.bean.FollowBean;
import com.tsingteng.cosfun.bean.NotificationBean;
import com.tsingteng.cosfun.bean.RecommenResp;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;

import java.util.List;


public class AttentPresenter extends BasePresenter<AttentContract.IAttentView> implements AttentContract.IAttentPresenter {
    AttentContract.IAttentView view;
    private final AttentListModel attentListModel;

    public AttentPresenter() {
        attentListModel = new AttentListModel();
    }

    @Override
    public void loginFollowFans(String follow_id,int position) {
        view = getView();
        RxObserver<FollowBean> rxObserver = new RxObserver<FollowBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(FollowBean followBean) {
                view.getFollowResult(followBean, position);
            }
        };

        attentListModel.getFollowNotification(follow_id, rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void loginNoFollow(String follow_id,int position) {
        view = getView();
        RxObserver<FollowBean> rxObserver = new RxObserver<FollowBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(FollowBean followBean) {
                view.getNoFollowResult(followBean, position);
            }
        };

        attentListModel.getNoFollowNotification(follow_id, rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void getAttentList(String follower_id, int page) {
        view = getView();
        RxObserver<AttentFansbean> rxObserver = new RxObserver<AttentFansbean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(AttentFansbean attentFansbean) {
                view.getShowListData(attentFansbean);
            }
        };

        attentListModel.getAttentList(follower_id, page, rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void getReList() {
        view = getView();
        RxObserver<RecommenResp> rxObserver = new RxObserver<RecommenResp>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(RecommenResp attentRecommendbeans) {
                view.getShowListData(attentRecommendbeans);
            }

        };

        attentListModel.getReList( rxObserver);
        addDisposable(rxObserver);
    }

    @Override
    public void getFansList(String follower_id, int page) {
        view = getView();
        RxObserver<AttentFansbean> rxObserver = new RxObserver<AttentFansbean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {

            }

            @Override
            protected void onSuccess(AttentFansbean attentFansbean) {
                view.getShowListData(attentFansbean);
            }
        };

        attentListModel.getFansList(follower_id, page, rxObserver);
        addDisposable(rxObserver);
    }
}
